package com.zlh;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zlh.mapper.EmpMapper;
import com.zlh.pojo.Emp;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
public class EmpQueryWrapper {
    @Autowired
    private EmpMapper empMapper;
    @Test
    public void test() {
        // 查询姓名中包含“李”且薪资大于等于5000的员工的 id, name, phone, salary字段
        QueryWrapper<Emp> queryWrapper = new QueryWrapper<>();
        queryWrapper.like("name", "李")
                .ge("salary", 5000)
                .select("id", "name", "phone", "salary");

        List<Emp> emps = empMapper.selectList(queryWrapper);
        emps.forEach(System.out::println);
    }
}
